/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-15 09:10:58
 * @LastEditTime : 2023-06-15 09:21:34
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\FileManagement.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, DelDataButton, AnnexButton } from '../Common/options'

export const FileManagement = async ({ OptionsEvent, oneData, Permission, actionRef }) => {
    let dataList = {
        hideInSearch: true,
        pageSize: 10,
        params: { infoManageUuid: oneData.uuid },
        initialValues: { infoManageUuid: oneData.uuid },
        get: API_LIST([oneData.uuid])['getInfoManageDetail'],
        added: 'posInfoManageDetail',
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="添加附件" />],
        columns: [
            commonTableList.uuid,
            {
                title: 'infoManageUuid',
                dataIndex: 'infoManageUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            { ...commonTableList.tableName, title: '文件名称', width: 300 },
            { ...commonTableList.sortId, width: 300 },
            {
                dataIndex: 'attachmentUuid',
                title: '文件附件',
                valueType: 'upload',
                valueFile: [1, 2, 3, 4, 5],
                fileUrl: 'fileUrl',
                rules: true,
                hideInTable: true,
            },
            {
                dataIndex: 'fileUrl',
                title: '文件附件',
                valueType: 'hidden',
                hideInSearch: true,
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
                width: 400,
            },
            {
                dataIndex: 'coverAttachmentUuid',
                title: '封面附件',
                valueType: 'upload',
                valueFile: [1],
                fileUrl: 'fileUrl',
                hideInTable: true,
            },
            {
                dataIndex: 'coverUrl',
                title: '封面附件',
                valueType: 'hidden',
                hideInSearch: true,
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
                width: 400,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, fileUrl, coverUrl } = record
                    return [
                        fileUrl && <AnnexButton OptionsEvent={OptionsEvent} key="one" url={fileUrl} title="查看附件" />,
                        coverUrl && (
                            <AnnexButton OptionsEvent={OptionsEvent} key="two" url={coverUrl} title="查看封面" />
                        ),
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url="InfoManageDetail"
                            uuid={uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return dataList
}
